<!--  -->
<template>
  <div>
    <!-- 有子菜单 -->
    <el-submenu :index="baseUrl" :popper-append-to-body="true">
      <template slot="title">
        <i :class="routes.meta.icon"></i>
        <span>{{ routes.meta.title }}</span>
      </template>
      <template v-for="childrenItem in routes.children">
        <menuItem
          v-if="!childrenItem.children"
          :baseUrl="baseUrl"
          :routes="childrenItem"
          :key="childrenItem.path"
        />
        <subMenu
          v-if="childrenItem.children"
          :baseUrl="baseUrl + '/' + childrenItem.path"
          :routes="childrenItem"
          :key="childrenItem.path"
        />
      </template>
    </el-submenu>
  </div>
</template>

<script>
import menuItem from "./menuItem";
export default {
  name: "subMenu",
  props: {
    baseUrl: {
      type: String,
      default: ""
    },
    routes: {
      type: Object
    }
  },
  components: {
    menuItem
  },
  data() {
    return {};
  },
  computed: {},
  watch: {},
  //方法集合
  methods: {},
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {} //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang="scss" scoped>
.el-menu--collapse > div > .el-submenu > .el-submenu__title span {
  height: 0;
  width: 0;
  overflow: hidden;
  visibility: hidden;
  display: inline-block;
}
</style>
